const config = require('../common/config');
const {tokenPrivateKey} = config;

const jwt = require('jsonwebtoken');

const jwtObj = {
  // 生成token
  createToken(userInfo) {
    try {
      return jwt.sign(userInfo, tokenPrivateKey, {
        expiresIn: '5d' // 授权时效5days
      });
    } catch (e) {
      return {
        code: -1, msg: 'token生成失败'
      }
    }

  }

};

module.exports = jwtObj;
